<?php
/**
 * we7_baiduappdemo百度小程序接口定义
 *
 * @author 微擎团队
 * @url
 */
defined('IN_IA') or exit('Access Denied');

class Yts_qiyeModuleBaiduapp extends WeModuleBaiduapp {

	// ims_yts_qiye_article
	// ims_yts_qiye_banner
	// ims_yts_qiye_category
	// ims_yts_qiye_contact
	// ims_yts_qiye_interface
	// ims_yts_qiye_nav
	// ims_yts_qiye_product
	// ims_yts_qiye_seo
	// ims_yts_qiye_setting
	// private http://127.0.0.1/wq/app/index.php?i=1&t=0&v=v1.0.1&setting_id=1&from=baiduapp&c=entry&a=baiduapp&do=Sysinfo&uniacid=1&m=yts_qiye
	private $setting_id;
	public function __construct(){
		if($_GET['setting_id']){
			$this->setting_id = $_GET['setting_id'];
		}else{
			$this->setting_id = 1;
		}
	}
	
	
	
	/**
	 * 图片补全URL路径
	 * params  string
	 * return string
	*/
	
	private function attach($img_path){
		global $_W;
		if(!$img_path){
			return  $img_path;
		}
		if(strpos($img_path,'http://') !== false OR strpos($img_path,'https://') !== false){
			return  $img_path;
		}else{
			return $_W['siteroot'] . 'attachment/'.$img_path;
		}
	}

	/**
	 * *请求接口
	 * 
	 * */
	private function http_json($url){
		$response = ihttp_get($url);
		$content = $response['content'];

		// var_dump($url);
		$response_data = json_decode($content ,true);

		return $response_data ;
	}


	/* *
	 * * 内容数组格式化
	 * * $array_content 
	 * $url 小程序URL跳转路径
	 * */
	private function fromat_content($array_content = array(),$url = ''){


		foreach ($array_content as $keys => $vals) {
			$array_content[$keys]['img_path'] =  $this->attach($vals['img_path']);
			$array_content[$keys]['images'] = $array_content[$keys]['img_path'];
			$html_message = htmlspecialchars_decode($array_content[$keys]['message']);
			$array_content[$keys]['description'] = mb_substr(strip_tags($html_message), 0, 50);


			$array_content[$keys]['addtime'] = date('Y-m-d',$vals['add_time']);
			if($url){
				$array_content[$keys]['url'] = $url.$vals['id'];
			}
			
		}

		return $array_content;
	}

	/**
	 * 数据接口获取函数
	 * params type string;args array
	 * return array
	*/
	private function Interfaces($type_name,$args = array()){
		
		// var_dump($this->setting_id);
		$setting_id = $this->setting_id;

		$interface_id_by_info = pdo_get('yts_qiye_interface',array('setting_id'=>$setting_id));
		
		$page = $args['page'];
		$pageNum = $args['pageNum'];
		if(!$page ){
			$page = 1;
		}
		if(!$pageNum){
			$pageNum = 10;
		}
		// $interface_id_by_info['status'] = 1;
		// $interface_id_by_info['type'] = 2;
		if($interface_id_by_info['status']){
		
			//接口类型
			if($interface_id_by_info['type'] == 1){
			//织梦接口
				if($type_name == 'seo'){

				}
				if($type_name == 'banner'){
					
				}
				if($type_name == 'contact'){

				}
				if($type_name == 'news'){

				}
				if($type_name == 'news_index'){

				}

				if($type_name == 'news_index'){

				}

				if($type_name == 'news_list'){
				}

				if($type_name == 'news_details'){

				}
				if($type_name == 'product_list'){

				}
				if($type_name == 'product_index'){

				}
				if($type_name == 'product_details'){

				}

			}elseif($interface_id_by_info['type'] == 2){
			//帝国接口
				
				$banner_url = $interface_id_by_info['site'] . '/e/extend/lskapp/api.php?at=ttnews/pic_getlist&strlen=0';
				$index_url = $interface_id_by_info['site'] .'/e/extend/lskapp/api.php?at=ttnews/qnews_getlist&type=index';
				$list_url  = $interface_id_by_info['site'] . '/e/extend/lskapp/api.php?at=ttnews/qnews_getlist&type=list';
				$content_url = $interface_id_by_info['site'] . '/e/extend/lskapp/api.php?at=ttnews/qnews_getinfo';
				$cat_url = $interface_id_by_info['site'] . '/e/extend/lskapp/api.php?at=ttnews/qcat_getlist';

				if($type_name == 'seo'){
					$cid= $args['cid'];
					$id = $args['id'];
	
					if(!$cid){
						$category_name = "全部";
					}
	
					$sitename_id_by = pdo_get('yts_qiye_setting',array('id'=>$setting_id),'sitename');
					$sitename = $sitename_id_by['sitename'];
	
					$p = array('/{sitename}/','/{category_name}/');
					$r = array($sitename,$category_name);
	
					$types = $args['type_position'];
					if($types){
	
						$seo_id_by_info = pdo_get('yts_qiye_seo',array('type'=>$types,'setting_id'=>$setting_id));
						$seo_id_by_info['seo_img'] = $this->attach($seo_id_by_info['seo_img']);
	
	
						if(($types == 'news' OR $types == 'product') AND $cid){
				
							$category_id_title = pdo_get('yts_qiye_category',array('id'=>$cid),'title');


							// $dg_api_url = 'http://dg.smlou.com/e/extend/lskapp/api.php?at=ttnews/qcat_getlist&cid=2';
							$dg_api_url = $cat_url.'&cid='.$cid;
							$response_data = $this->http_json($dg_api_url);
							$category_name = $response_data['data'];

							$r = array($sitename,$category_name);

						}
						if($types == 'news_details'){
							
							// $dg_api_url = 'http://dg.smlou.com/e/extend/lskapp/api.php?at=ttnews/qnews_getinfo&id='.$id;
							$dg_api_url =  $content_url.'&id='.$id;
							$response_data = $this->http_json($dg_api_url);
							$article_id_info = $response_data['data'];
							$title = $article_id_info['title'];
							$keywords =  $article_id_info['keywords'];
							$ftitle =  $article_id_info['ftitle'];
							$img_path = $this->attach($article_id_info['imgages']);
							$html_message = htmlspecialchars_decode($article_id_info['message']);
							$description = mb_substr(strip_tags($html_message), 0, 50);
							$time = date('Y-m-d H:i:s',$article_id_info['add_time']);
							// $dg_api_urls = 'http://dg.smlou.com/e/extend/lskapp/api.php?at=ttnews/qcat_getlist&cid=2';
							$dg_api_urls = $cat_url.'&cid='.$cid;
							$response_data = $this->http_json($dg_api_urls);
							$category_name = $response_data['data'];
							$seo_id_by_info['seo_img'] = $img_path;
							$seo_id_by_info['seo_articleTitle'] = $ftitle;
							$seo_id_by_info['seo_description'] = $description;
							$seo_id_by_info['seo_time'] = $time;
							$p = array('/{sitename}/','/{category_name}/','/{title}/','/{keywords}/');
							$r = array($sitename,$category_name,$title,$keywords);
						}
	
						if($types == 'product_details'){
							// $dg_api_url = 'http://dg.smlou.com/e/extend/lskapp/api.php?at=ttnews/qnews_getinfo&id='.$id;
							$dg_api_url =  $content_url.'&id='.$id;
							$response_data = $this->http_json($dg_api_url);
							$article_id_info = $response_data['data'];
							$title = $article_id_info['title'];
							$keywords =  $article_id_info['keywords'];
							$ftitle =  $article_id_info['ftitle'];
							$img_path = $this->attach($article_id_info['imgages']);
							$html_message = htmlspecialchars_decode($article_id_info['message']);
							$description = mb_substr(strip_tags($html_message), 0, 50);
							$time = date('Y-m-d H:i:s',$article_id_info['add_time']);
							// $dg_api_urls = 'http://dg.smlou.com/e/extend/lskapp/api.php?at=ttnews/qcat_getlist&cid=2';
							$dg_api_urls = $cat_url.'&cid='.$cid;

							$response_data = $this->http_json($dg_api_urls);
							$category_name = $response_data['data'];
							$seo_id_by_info['seo_img'] = $img_path;
							$seo_id_by_info['seo_articleTitle'] = $ftitle;
							$seo_id_by_info['seo_description'] = $description;
							$seo_id_by_info['seo_time'] = $time;
							$p = array('/{sitename}/','/{category_name}/','/{title}/','/{keywords}/');
							$r = array($sitename,$category_name,$title,$keywords);
						}
	
	
	
	
						foreach ($seo_id_by_info as $key => $value) {
							$seo_id_by_info[$key] = preg_replace($p,$r,$value);
						}
	
	
						return $seo_id_by_info;
					}
				}
				if($type_name == 'banner'){
					// $content = '{"errcode":0,"errmsg":"ok","data":[{"id":"79","cid":"58","title":"ceahsa \u7231\u5c31\u662f\u5927\u963f\u6253","ftitle":"\u526f\u6807\u9898","images":"http:\/\/127.0.0.1\/dg\/d\/file\/p\/2019\/07-12\/dc59a59f3f4c858f99151a5697c2edc1.jpg","keywords":"\u4f60\u597d \u6d4b\u8bd5 \u90a3\u8fd8","description":"\u7b80\u4ecb\u7b80\u4ecb\u7b80\u4ecb\u7b80\u4ecb"},{"id":"72","cid":"35","title":"\u4e2d\u56fd\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u8fd0\u62b5","ftitle":"","images":"http:\/\/cimg21.163.com\/cnews\/2008\/5\/8\/200805080616347228c.jpg","keywords":"","description":"\u4e2d\u56fd\u653f\u5e9c\u5411\u7f05\u7538\u63d0\u4f9b\u7684\u4eba\u9053\u4e3b\u4e49\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u5f53\u65e5\u7a7a\u8fd0\u62b5\u8fbe\u4ef0\u5149\u56fd\u9645\u673a\u573a\u3002\u8fd9\u6279\u7269\u8d44\u4e3b\u8981\u5305\u62ec\u5e10\u7bf7\u3001\u6bdb\u5dfe\u88ab\u548c\u538b\u7f29\u997c\u5e72\u7b49\uff0c\u4ef7\u503c50\u4e07\u7f8e\u5143\u3002\u4e2d\u56fd\u653f\u5e9c\u8fd8\u5411\u7f05\u7538\u63d0\u4f9b\u4e8650\u4e07\u7f8e\u5143\u7684\u73b0\u6c47\u63f4\u52a9\u3002"},{"id":"71","cid":"37","title":"\u5965\u8fd0\u5723\u706b\u6210\u529f\u767b\u9876\u73e0\u5cf0","ftitle":"","images":"http:\/\/cimg20.163.com\/cnews\/2008\/5\/8\/2008050809305433312.jpg","keywords":"","description":"\u5965\u8fd0\u706b\u70ac\u3001\u63a5\u529b\u73e0\u5cf0\u4f20\u9012\u6d3b\u52a8\u5706\u6ee1\u7ed3\u675f\uff0c\u643a\u5e26\u5723\u706b\u7684\u7a81\u51fb\u961f\u5458\u5168\u90e8\u767b\u9876\uff0c\u5e76\u8fdb\u884c\u4e86\u5723\u706b\u7684\u4f20\u9012\u3002\u5723\u706b\u5728\u73e0\u5cf0\u4e4b\u5dc5\u4f20\u9012\uff0c\u9996\u6b21\u6210\u529f\u70b9\u4eae\u4e16\u754c\u6700\u9ad8\u5cf0\uff0c\u521b\u9020\u4e86\u5965\u8fd0\u5723\u706b\u767b\u4e0a\u4e16\u754c\u7b2c\u4e09\u6781\u7684\u65b0\u7eaa\u5f55\u3002"},{"id":"70","cid":"35","title":"\u4fc4\u7f57\u65af\u7b2c\u4e09\u4efb\u603b\u7edf\u6885\u5fb7","ftitle":"","images":"http:\/\/cimg21.163.com\/cnews\/2008\/5\/7\/20080507165459698f2.jpg","keywords":"","description":"\u57283\u67082\u65e5\u4fc4\u7f57\u65af\u603b\u7edf\u9009\u4e3e\u4e2d\u80dc\u51fa\u7684\u5f53\u9009\u603b\u7edf\u5fb7\u7c73\u7279\u91cc-\u6885\u5fb7\u97e6\u6770\u592b, \u4e8e\u5f53\u5730\u65f6\u95f47\u65e512\u65f6\u8fc7\u540e(\u5317\u4eac\u65f6\u95f4\u4e0b\u53484\u65f6)\u5728\u514b\u91cc\u59c6\u6797\u5bab\u6b63\u5f0f\u5ba3\u8a93\u5c31\u804c\uff0c\u6210\u4e3a\u4fc4\u7f57\u65af\u7b2c\u4e09\u4f4d\u603b\u7edf\u3002"}]}';
					
					if(!$args['type_position'] OR $args['type_position'] > 2){
						$args['type_position'] = 1;
					}



					if($args['type_position'] ==1){
						
						
						$dg_api_url = $banner_url.$interface_id_by_info['banner_api'];
						
					}elseif($args['type_position'] == 2){
						$dg_api_url = $banner_url.$interface_id_by_info['banner_list_api'];
					}
					
					
					$response_data = $this->http_json($dg_api_url);
					$data = $response_data['data'];
				
					foreach ($data as $key => $value) {
						$data[$key]['type_skip'] = 2;
						$data[$key]['type_position'] = 1;
						$data[$key]['url'] = '/pages/content/content?type=news&id='.$value['id'];
					}

					return $data;
					// type_skip
					// type_position

				}
				if($type_name == 'contact'){
					$contact_info = pdo_get('yts_qiye_contact',array('setting_id'=>$setting_id));
					$contact_info['banner'] =   $this->attach($contact_info['banner']);
					$contact_info['pictures'] =   $this->attach($contact_info['pictures']);
					$contact_info['logo'] =   $this->attach($contact_info['logo']);
					return $contact_info;
				}
				if($type_name == 'news'){

				}
				if($type_name == 'news_index'){
					// http://127.0.0.1/dg/e/extend/lskapp/api.php?at=ttnews/qnews_getlist&type=index&pageNum=10&cids=2

					// $contents = '{"errcode":0,"errmsg":"ok","data":[{"title":"\u5168\u90e8","type":"all","id":0,"list":[{"id":"78","title":"\u4e2d\u56fd\u7537\u4e52\u7b2c16\u6b21\u6367\u8d77\u65af\u97e6\u601d\u6797\u676f","ftitle":"","thimglist":[],"pictype":1,"onclick":28,"cid":"37","price":0,"diggtop":0,"add_time":"1355124518","addtime":"2012-12-10","message":"","images":"http:\/\/img1.qq.com\/sports\/pics\/8865\/8865651.jpg","uid":"1"},{"id":"77","title":"\u79d1\u6bd4\u4e13\u4e3a\u5927\u573a\u9762\u800c\u751f","ftitle":"","thimglist":[],"pictype":1,"onclick":0,"cid":"37","price":0,"diggtop":0,"add_time":"1355124517","addtime":"2012-12-10","message":"","images":"http:\/\/img1.qq.com\/sports\/pics\/10300\/10300435.jpg","uid":"1"},{"id":"76","title":"\u201c\u6700\u7f8e\u6e05\u6d01\u5de5\u201d\u539f\u662f\u300a\u8d64\u58c1\u300b\u5bab\u5973","ftitle":"","thimglist":[],"pictype":1,"onclick":1,"cid":"36","price":0,"diggtop":0,"add_time":"1355124516","addtime":"2012-12-10","message":"","images":"http:\/\/img1.qq.com\/ent\/pics\/10290\/10290791.jpg","uid":"1"},{"id":"75","title":"\u5c39\u99a8\u5927\u80c6\u4eae\u76f8\u300a\u7537\u4eba\u88c5\u300b \u5ae9\u80a4\u7f8e\u817f\u52fe\u4eba\u9b42","ftitle":"","thimglist":[],"pictype":1,"onclick":0,"cid":"36","price":0,"diggtop":0,"add_time":"1355124515","addtime":"2012-12-10","message":"","images":"http:\/\/img1.qq.com\/ent\/pics\/10290\/10290789.jpg","uid":"1"},{"id":"74","title":"\u4f20\u5f20\u827a\u8c0b\u56e0\u6267\u5bfc\u5965\u8fd0\u8eab\u4ef7\u6da85\u500d","ftitle":"","thimglist":[],"pictype":1,"onclick":0,"cid":"36","price":0,"diggtop":0,"add_time":"1355124514","addtime":"2012-12-10","message":"","images":"http:\/\/cimg21.163.com\/ent\/2008\/5\/8\/200805080924559c424.jpg","uid":"1"},{"id":"73","title":"\u5f20\u66fc\u7389\u5e7f\u544a\u5199\u771f\u82b1\u7d6e\u66dd\u5149 \u6d41\u9732\u4f18\u96c5\u4ece\u5bb9","ftitle":"","thimglist":[],"pictype":1,"onclick":0,"cid":"36","price":0,"diggtop":0,"add_time":"1355124513","addtime":"2012-12-10","message":"","images":"http:\/\/cimg21.163.com\/ent\/2008\/5\/8\/2008050811191076090.jpg","uid":"1"},{"id":"72","title":"\u4e2d\u56fd\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u8fd0\u62b5\u7f05\u7538\u4ef0\u5149(\u7ec4\u56fe)","ftitle":"","thimglist":[],"pictype":1,"onclick":11,"cid":"35","price":0,"diggtop":0,"add_time":"1355124512","addtime":"2012-12-10","message":"","images":"http:\/\/cimg21.163.com\/cnews\/2008\/5\/8\/200805080616347228c.jpg","uid":"1"},{"id":"71","title":"\u5965\u8fd0\u5723\u706b\u6210\u529f\u767b\u9876\u73e0\u5cf0","ftitle":"","thimglist":[],"pictype":1,"onclick":1,"cid":"37","price":0,"diggtop":0,"add_time":"1355124511","addtime":"2012-12-10","message":"","images":"http:\/\/cimg20.163.com\/cnews\/2008\/5\/8\/2008050809305433312.jpg","uid":"1"},{"id":"70","title":"\u4fc4\u7f57\u65af\u7b2c\u4e09\u4efb\u603b\u7edf\u6885\u5fb7\u97e6\u6770\u592b\u5ba3\u8a93\u5c31\u804c","ftitle":"","thimglist":[],"pictype":1,"onclick":2,"cid":"35","price":0,"diggtop":0,"add_time":"1355124510","addtime":"2012-12-10","message":"","images":"http:\/\/cimg21.163.com\/cnews\/2008\/5\/7\/20080507165459698f2.jpg","uid":"1"},{"id":"69","title":"\u5e7f\u4e1c\u4e39\u971e\u5c71\u53d1\u73b0\u5de8\u578b\u201c\u9752\u94dc\u5251\u201c(\u7ec4\u56fe)","ftitle":"","thimglist":[],"pictype":1,"onclick":24,"cid":"34","price":0,"diggtop":0,"add_time":"1355124509","addtime":"2012-12-10","message":"","images":"","uid":"1"}]},{"cid":"2","title":"\u65b0\u95fb\u4e2d\u5fc3","pcid":0,"scid":"|34|35|36|37|","type":1,"list":[{"id":"78","title":"\u4e2d\u56fd\u7537\u4e52\u7b2c16\u6b21\u6367\u8d77\u65af\u97e6\u601d\u6797\u676f","ftitle":"","thimglist":[],"pictype":1,"onclick":28,"cid":"37","price":0,"diggtop":0,"smalltext":"\u7b2c49\u5c4a\u4e16\u4e52\u8d5b\u7537\u56e2\u51b3\u8d5b\u7684\u4e89\u593a\uff0c\u4e2d\u56fd\u961f\u6700\u7ec8\u51ed\u501f\u9a6c\u7433\u3001\u738b\u7693\u548c\u738b\u52b1\u52e4\u4e09\u5458\u864e\u5c06\u7684\u51fa\u8272\u53d1\u6325\u4ee53\u6bd40\u5e72\u51c0\u5229\u843d\u7684\u51fb\u8d25\u97e9\u56fd\u961f\uff0c\u5ef6\u7eed\u4e86\u4e16\u4e52\u8d5b\u4e0a\u9022\u97e9\u5fc5\u80dc\u7684\u5386\u53f2\uff0c\u5386\u53f2\u4e0a\u7b2c16\u6b21\u6367\u8d77\u65af\u97e6\u601d\u6797\u676f\uff01","add_time":"1355124518","addtime":"2012-12-10","message":"","images":"http:\/\/img1.qq.com\/sports\/pics\/8865\/8865651.jpg","uid":"1"},{"id":"77","title":"\u79d1\u6bd4\u4e13\u4e3a\u5927\u573a\u9762\u800c\u751f","ftitle":"","thimglist":[],"pictype":1,"onclick":0,"cid":"37","price":0,"diggtop":0,"smalltext":"\u6210\u540d\u8fd9\u4e48\u4e45\u8fdc\u4e86\uff0c\u79d1\u6bd4\u7ec8\u4e8e\u88ab\u8bc1\u5b9e\u201c\u6700\u6709\u4ef7\u503c\u201d\u3002","add_time":"1355124517","addtime":"2012-12-10","message":"","images":"http:\/\/img1.qq.com\/sports\/pics\/10300\/10300435.jpg","uid":"1"},{"id":"76","title":"\u201c\u6700\u7f8e\u6e05\u6d01\u5de5\u201d\u539f\u662f\u300a\u8d64\u58c1\u300b\u5bab\u5973","ftitle":"","thimglist":[],"pictype":1,"onclick":1,"cid":"36","price":0,"diggtop":0,"smalltext":"2008\u5317\u4eac\u8f66\u5c554\u670823\u65e5\u521a\u521a\u843d\u5e55\uff0c\u201c\u6700\u7f8e\u6e05\u6d01\u5de5\u201d\u8fc5\u901f\u8d70\u7ea2\u7f51\u7edc\u3002\u8fd9\u4f4d\u8eb2\u5728\u8f66\u5c55\u89d2\u843d\u6beb\u4e0d\u8d77\u773c\u7684\u6e05\u6d01\u5de5\u7f8e\u5973\uff0c\u5728\u6709\u5fc3\u4eba\u58eb\u7684\u5077\u62cd\u4e0b\uff0c\u7167\u7247\u4e00\u7ecf\u653e\u5230\u7f51\u4e0a\u5c31\u5f15\u6765\u7f51\u53cb\u70ed\u6367\u3002","add_time":"1355124516","addtime":"2012-12-10","message":"","images":"http:\/\/img1.qq.com\/ent\/pics\/10290\/10290791.jpg","uid":"1"},{"id":"75","title":"\u5c39\u99a8\u5927\u80c6\u4eae\u76f8\u300a\u7537\u4eba\u88c5\u300b \u5ae9\u80a4\u7f8e\u817f\u52fe\u4eba\u9b42","ftitle":"","thimglist":[],"pictype":1,"onclick":0,"cid":"36","price":0,"diggtop":0,"smalltext":"\u8521\u660e\u4eae\u5f92\u5f1f\u4e4b\u4f5c\u300a\u5e2e\u5e2e\u6211\u7231\u795e\u300b\u5973\u4e3b\u89d2\u5c39\u99a8\u7684\u5927\u80c6\u51fa\u6f14\uff0c\u8db3\u4ee5\u6311\u6218\u300a\u8272\u6212\u300b\u4e2d\u6c64\u552f\u7684\u60c5\u8272\u3002\u5c39\u99a8\u57285\u6708\u4efd\u7684\u300a\u7537\u4eba\u88c5\u300b\u4e2d\u6709\u51fa\u8272\u4eae\u76f8\u3002","add_time":"1355124515","addtime":"2012-12-10","message":"","images":"http:\/\/img1.qq.com\/ent\/pics\/10290\/10290789.jpg","uid":"1"},{"id":"74","title":"\u4f20\u5f20\u827a\u8c0b\u56e0\u6267\u5bfc\u5965\u8fd0\u8eab\u4ef7\u6da85\u500d","ftitle":"","thimglist":[],"pictype":1,"onclick":0,"cid":"36","price":0,"diggtop":0,"smalltext":"2008\u5317\u4eac\u5965\u8fd0\u4f1a\u7684\u5f00\u5e55\u5f0f\u5df2\u5f00\u59cb\u4e86\u5f69\u6392\uff0c\u4f5c\u4e3a\u603b\u5bfc\u6f14\u7684\u5f20\u827a\u8c0b\u5766\u8a00\uff0c\u6267\u5bfc\u5965\u8fd0\u4f1a\u7684\u538b\u529b\u8fdc\u5927\u8fc7\u6267\u5bfc\u7535\u5f71\u3002\u800c\u7531\u4e8e\u5bfc\u6f14\u4e86\u5965\u8fd0\u4f1a\u8fd9\u6837\u7684\u4eba\u7c7b\u76db\u5178\uff0c\u5f20\u827a\u8c0b\u5bfc\u6f14\u8eab\u4ef7\u4e0a\u6da8\u4e865\u500d\u4ee5\u4e0a\u3002","add_time":"1355124514","addtime":"2012-12-10","message":"","images":"http:\/\/cimg21.163.com\/ent\/2008\/5\/8\/200805080924559c424.jpg","uid":"1"},{"id":"73","title":"\u5f20\u66fc\u7389\u5e7f\u544a\u5199\u771f\u82b1\u7d6e\u66dd\u5149 \u6d41\u9732\u4f18\u96c5\u4ece\u5bb9","ftitle":"","thimglist":[],"pictype":1,"onclick":0,"cid":"36","price":0,"diggtop":0,"smalltext":"\u5f20\u66fc\u7389\u6700\u8fd1\u4e00\u7ec4\u5e7f\u544a\u5199\u771f\u82b1\u7d6e\u66dd\u5149\uff0c\u7167\u7247\u4e2d\u7684\u5f20\u66fc\u7389\u98ce\u91c7\u4f9d\u65e7\uff0c\u900f\u9732\u4f18\u96c5\u6c14\u8d28\u3002","add_time":"1355124513","addtime":"2012-12-10","message":"","images":"http:\/\/cimg21.163.com\/ent\/2008\/5\/8\/2008050811191076090.jpg","uid":"1"},{"id":"72","title":"\u4e2d\u56fd\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u8fd0\u62b5\u7f05\u7538\u4ef0\u5149(\u7ec4\u56fe)","ftitle":"","thimglist":[],"pictype":1,"onclick":11,"cid":"35","price":0,"diggtop":0,"smalltext":"\u4e2d\u56fd\u653f\u5e9c\u5411\u7f05\u7538\u63d0\u4f9b\u7684\u4eba\u9053\u4e3b\u4e49\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u5f53\u65e5\u7a7a\u8fd0\u62b5\u8fbe\u4ef0\u5149\u56fd\u9645\u673a\u573a\u3002\u8fd9\u6279\u7269\u8d44\u4e3b\u8981\u5305\u62ec\u5e10\u7bf7\u3001\u6bdb\u5dfe\u88ab\u548c\u538b\u7f29\u997c\u5e72\u7b49\uff0c\u4ef7\u503c50\u4e07\u7f8e\u5143\u3002\u4e2d\u56fd\u653f\u5e9c\u8fd8\u5411\u7f05\u7538\u63d0\u4f9b\u4e8650\u4e07\u7f8e\u5143\u7684\u73b0\u6c47\u63f4\u52a9\u3002","add_time":"1355124512","addtime":"2012-12-10","message":"","images":"http:\/\/cimg21.163.com\/cnews\/2008\/5\/8\/200805080616347228c.jpg","uid":"1"},{"id":"71","title":"\u5965\u8fd0\u5723\u706b\u6210\u529f\u767b\u9876\u73e0\u5cf0","ftitle":"","thimglist":[],"pictype":1,"onclick":1,"cid":"37","price":0,"diggtop":0,"smalltext":"\u5965\u8fd0\u706b\u70ac\u3001\u63a5\u529b\u73e0\u5cf0\u4f20\u9012\u6d3b\u52a8\u5706\u6ee1\u7ed3\u675f\uff0c\u643a\u5e26\u5723\u706b\u7684\u7a81\u51fb\u961f\u5458\u5168\u90e8\u767b\u9876\uff0c\u5e76\u8fdb\u884c\u4e86\u5723\u706b\u7684\u4f20\u9012\u3002\u5723\u706b\u5728\u73e0\u5cf0\u4e4b\u5dc5\u4f20\u9012\uff0c\u9996\u6b21\u6210\u529f\u70b9\u4eae\u4e16\u754c\u6700\u9ad8\u5cf0\uff0c\u521b\u9020\u4e86\u5965\u8fd0\u5723\u706b\u767b\u4e0a\u4e16\u754c\u7b2c\u4e09\u6781\u7684\u65b0\u7eaa\u5f55\u3002","add_time":"1355124511","addtime":"2012-12-10","message":"","images":"http:\/\/cimg20.163.com\/cnews\/2008\/5\/8\/2008050809305433312.jpg","uid":"1"},{"id":"70","title":"\u4fc4\u7f57\u65af\u7b2c\u4e09\u4efb\u603b\u7edf\u6885\u5fb7\u97e6\u6770\u592b\u5ba3\u8a93\u5c31\u804c","ftitle":"","thimglist":[],"pictype":1,"onclick":2,"cid":"35","price":0,"diggtop":0,"smalltext":"\u57283\u67082\u65e5\u4fc4\u7f57\u65af\u603b\u7edf\u9009\u4e3e\u4e2d\u80dc\u51fa\u7684\u5f53\u9009\u603b\u7edf\u5fb7\u7c73\u7279\u91cc-\u6885\u5fb7\u97e6\u6770\u592b, \u4e8e\u5f53\u5730\u65f6\u95f47\u65e512\u65f6\u8fc7\u540e(\u5317\u4eac\u65f6\u95f4\u4e0b\u53484\u65f6)\u5728\u514b\u91cc\u59c6\u6797\u5bab\u6b63\u5f0f\u5ba3\u8a93\u5c31\u804c\uff0c\u6210\u4e3a\u4fc4\u7f57\u65af\u7b2c\u4e09\u4f4d\u603b\u7edf\u3002","add_time":"1355124510","addtime":"2012-12-10","message":"","images":"http:\/\/cimg21.163.com\/cnews\/2008\/5\/7\/20080507165459698f2.jpg","uid":"1"},{"id":"69","title":"\u5e7f\u4e1c\u4e39\u971e\u5c71\u53d1\u73b0\u5de8\u578b\u201c\u9752\u94dc\u5251\u201c(\u7ec4\u56fe)","ftitle":"","thimglist":[],"pictype":1,"onclick":24,"cid":"34","price":0,"diggtop":0,"smalltext":"\u201c\u9752\u94dc\u5251\u201d\u201c\u9576\u5d4c\u201d\u5728\u6652\u5e03\u5ca9\u5ca9\u58c1\u4e0a\u3002\u201c\u9752\u94dc\u5251\u201d\u7591\u4f3c\u7eff\u8272\u690d\u7269\u6500\u9644\u5728\u5ca9\u58c1\u4e0a\u751f\u957f\u3002\u8bb0\u8005\u966a\u540c\u8fdc\u9053\u800c\u6765\u7684\u670b\u53cb\u6e38\u89c8\u4e16\u754c\u5730\u8d28\u516c\u56ed\u5e7f\u4e1c\u4e39\u971e\u5c71\uff0c\u5728\u9633\u5143\u77f3\u666f\u533a\u5185\uff0c\u7a81\u7136\u53d1\u73b0\u4e00\u628a\u9752\u94dc\u5251","add_time":"1355124509","addtime":"2012-12-10","message":"","images":"","uid":"1"}]}],"page":1,"page_total":4,"total":"33","catName":"\u5168\u90e8","catindex":0,"cid":0}';
					if($interface_id_by_info['news_index_api']){
					
						$dg_api_url = $index_url.$interface_id_by_info['news_index_api'];
						$response_data = $this->http_json($dg_api_url);
	
						$data = $response_data['data'];
	
						foreach ($data  as $keys => $vals) {
							foreach ($vals['list'] as $key => $val) {
								$vals['list'][$key]['url'] = '/pages/content/content?type=news&id='.$val['id'];
							}
							$data[$keys]['list'] = $vals['list'];
			
						}
					}

					return $data;
				
				}

				if($type_name == 'news_list'){
					// http://127.0.0.1/dg/e/extend/lskapp/api.php?at=ttnews/qnews_getlist&type=list&pageNum=10&cids=2,5&cid=2
					$cid = $args['cid'];
					
					if($interface_id_by_info['news_api']){
						$dg_api_url = $list_url.$interface_id_by_info['news_api'];
						$pam = '&page='.$page;
	
						if($cid){
							$pam.= '&cid='.$cid;
						}
	
						$response_data = $this->http_json($dg_api_url.$pam);
						foreach ($response_data['list'] as $key => $vals) {
							$response_data['list'][$key]['url'] = '/pages/content/content?type=news&id='.$vals['id'];
						}
					}
				
					return $response_data;
					
				}

				if($type_name == 'news_details'){
					
					// $content = '{"errcode":0,"errmsg":"ok","data":{"id":"15","category_id":"35","title":"\u4e2d\u56fd\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u8fd0\u62b5\u7f05\u7538\u4ef0\u5149(\u7ec4\u56fe)","ftitle":"","newstext":"<P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><CENTER><IMG src=\"http:\/\/cimg21.163.com\/cnews\/2008\/5\/7\/200805072245130b04b.jpg\" border=0><\/CENTER><P><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\">5\u67087\u65e5\uff0c\u5728\u7f05\u7538\u4ef0\u5149\u56fd\u9645\u673a\u573a\uff0c\u7f05\u7538\u7684\u5de5\u4f5c\u4eba\u5458\u5728\u642c\u8fd0\u4e2d\u56fd\u7684\u63f4\u52a9\u7269\u8d44\u3002<\/P><P style=\"TEXT-INDENT: 2em\">\u4e2d\u56fd\u653f\u5e9c\u5411\u7f05\u7538\u653f\u5e9c\u63d0\u4f9b\u7684\u4eba\u9053\u4e3b\u4e49\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u5f53\u65e5\u4e0b\u5348\u7a7a\u8fd0\u62b5\u8fbe\u4ef0\u5149\u56fd\u9645\u673a\u573a\u3002\u8fd9\u6279\u7d27\u6025\u7269\u8d44\u4e3b\u8981\u5305\u62ec\u5e10\u7bf7\u3001\u6bdb\u5dfe\u88ab\u548c\u538b\u7f29\u997c\u5e72\u7b49\uff0c\u4ef7\u503c50\u4e07\u7f8e\u5143\u3002\u4e2d\u56fd\u653f\u5e9c\u8fd8\u5411\u7f05\u7538\u653f\u5e9c\u63d0\u4f9b\u4e8650\u4e07\u7f8e\u5143\u7684\u73b0\u6c47\u63f4\u52a9\u3002\uff08\u65b0\u534e\uff09<\/P><P style=\"TEXT-INDENT: 2em\"><CENTER><IMG src=\"http:\/\/cimg20.163.com\/cnews\/2008\/5\/7\/20080507224541cc92d.jpg\" border=0><\/CENTER><P><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\">5\u67087\u65e5\uff0c\u5728\u7f05\u7538\u4ef0\u5149\u56fd\u9645\u673a\u573a\uff0c\u4e2d\u56fd\u9a7b\u7f05\u7538\u5927\u4f7f\u7ba1\u6728\uff08\u53f3\u4e8c\uff09\u4e0e\u63a5\u53d7\u4e2d\u56fd\u653f\u5e9c\u6350\u8d60\u7269\u8d44\u7684\u7f05\u7538\u793e\u4f1a\u798f\u5229\u3001\u6551\u6d4e\u548c\u5b89\u7f6e\u90e8\u90e8\u957f\u8c8c\u8c8c\u745e\u5c11\u5c06\uff08\u53f3\uff09\u63e1\u624b\u3002\uff08\u65b0\u534e\uff09<\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><CENTER><IMG src=\"http:\/\/cimg20.163.com\/cnews\/2008\/5\/7\/20080507224606aab55.jpg\" border=0><\/CENTER><P><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\">5\u67087\u65e5\uff0c\u5728\u7f05\u7538\u4ef0\u5149\u56fd\u9645\u673a\u573a\uff0c\u7f05\u7538\u7684\u5de5\u4f5c\u4eba\u5458\u5728\u642c\u8fd0\u4e2d\u56fd\u7684\u63f4\u52a9\u7269\u8d44\u3002<\/P><P style=\"TEXT-INDENT: 2em\">\u4e2d\u56fd\u653f\u5e9c\u5411\u7f05\u7538\u653f\u5e9c\u63d0\u4f9b\u7684\u4eba\u9053\u4e3b\u4e49\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u5f53\u65e5\u4e0b\u5348\u7a7a\u8fd0\u62b5\u8fbe\u4ef0\u5149\u56fd\u9645\u673a\u573a\u3002\u8fd9\u6279\u7d27\u6025\u7269\u8d44\u4e3b\u8981\u5305\u62ec\u5e10\u7bf7\u3001\u6bdb\u5dfe\u88ab\u548c\u538b\u7f29\u997c\u5e72\u7b49\uff0c\u4ef7\u503c50\u4e07\u7f8e\u5143\u3002\u4e2d\u56fd\u653f\u5e9c\u8fd8\u5411\u7f05\u7538\u653f\u5e9c\u63d0\u4f9b\u4e8650\u4e07\u7f8e\u5143\u7684\u73b0\u6c47\u63f4\u52a9\u3002\uff08\u65b0\u534e\uff09<\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><CENTER><IMG src=\"http:\/\/cimg20.163.com\/cnews\/2008\/5\/7\/2008050722463139852.jpg\" border=0><\/CENTER><P><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\">5\u67087\u65e5\uff0c\u5728\u7f05\u7538\u4ef0\u5149\u56fd\u9645\u673a\u573a\uff0c\u5de5\u4f5c\u4eba\u5458\u5728\u642c\u8fd0\u4e2d\u56fd\u7684\u63f4\u52a9\u7269\u8d44\u3002\uff08\u65b0\u534e\uff09<\/P><P style=\"TEXT-INDENT: 2em\">(\u672c\u6587\u6765\u6e90\uff1a\u65b0\u534e\u7f51  \u4f5c\u8005\uff1a\u5f20\u4e91\u98de)","images":"","add_time":"1355124455","addtime":"2012-12-10 15:27","message":"<P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><CENTER><IMG src=\"http:\/\/cimg21.163.com\/cnews\/2008\/5\/7\/200805072245130b04b.jpg\" border=0><\/CENTER><P><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\">5\u67087\u65e5\uff0c\u5728\u7f05\u7538\u4ef0\u5149\u56fd\u9645\u673a\u573a\uff0c\u7f05\u7538\u7684\u5de5\u4f5c\u4eba\u5458\u5728\u642c\u8fd0\u4e2d\u56fd\u7684\u63f4\u52a9\u7269\u8d44\u3002<\/P><P style=\"TEXT-INDENT: 2em\">\u4e2d\u56fd\u653f\u5e9c\u5411\u7f05\u7538\u653f\u5e9c\u63d0\u4f9b\u7684\u4eba\u9053\u4e3b\u4e49\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u5f53\u65e5\u4e0b\u5348\u7a7a\u8fd0\u62b5\u8fbe\u4ef0\u5149\u56fd\u9645\u673a\u573a\u3002\u8fd9\u6279\u7d27\u6025\u7269\u8d44\u4e3b\u8981\u5305\u62ec\u5e10\u7bf7\u3001\u6bdb\u5dfe\u88ab\u548c\u538b\u7f29\u997c\u5e72\u7b49\uff0c\u4ef7\u503c50\u4e07\u7f8e\u5143\u3002\u4e2d\u56fd\u653f\u5e9c\u8fd8\u5411\u7f05\u7538\u653f\u5e9c\u63d0\u4f9b\u4e8650\u4e07\u7f8e\u5143\u7684\u73b0\u6c47\u63f4\u52a9\u3002\uff08\u65b0\u534e\uff09<\/P><P style=\"TEXT-INDENT: 2em\"><CENTER><IMG src=\"http:\/\/cimg20.163.com\/cnews\/2008\/5\/7\/20080507224541cc92d.jpg\" border=0><\/CENTER><P><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\">5\u67087\u65e5\uff0c\u5728\u7f05\u7538\u4ef0\u5149\u56fd\u9645\u673a\u573a\uff0c\u4e2d\u56fd\u9a7b\u7f05\u7538\u5927\u4f7f\u7ba1\u6728\uff08\u53f3\u4e8c\uff09\u4e0e\u63a5\u53d7\u4e2d\u56fd\u653f\u5e9c\u6350\u8d60\u7269\u8d44\u7684\u7f05\u7538\u793e\u4f1a\u798f\u5229\u3001\u6551\u6d4e\u548c\u5b89\u7f6e\u90e8\u90e8\u957f\u8c8c\u8c8c\u745e\u5c11\u5c06\uff08\u53f3\uff09\u63e1\u624b\u3002\uff08\u65b0\u534e\uff09<\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><CENTER><IMG src=\"http:\/\/cimg20.163.com\/cnews\/2008\/5\/7\/20080507224606aab55.jpg\" border=0><\/CENTER><P><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\">5\u67087\u65e5\uff0c\u5728\u7f05\u7538\u4ef0\u5149\u56fd\u9645\u673a\u573a\uff0c\u7f05\u7538\u7684\u5de5\u4f5c\u4eba\u5458\u5728\u642c\u8fd0\u4e2d\u56fd\u7684\u63f4\u52a9\u7269\u8d44\u3002<\/P><P style=\"TEXT-INDENT: 2em\">\u4e2d\u56fd\u653f\u5e9c\u5411\u7f05\u7538\u653f\u5e9c\u63d0\u4f9b\u7684\u4eba\u9053\u4e3b\u4e49\u7d27\u6025\u63f4\u52a9\u7269\u8d44\u5f53\u65e5\u4e0b\u5348\u7a7a\u8fd0\u62b5\u8fbe\u4ef0\u5149\u56fd\u9645\u673a\u573a\u3002\u8fd9\u6279\u7d27\u6025\u7269\u8d44\u4e3b\u8981\u5305\u62ec\u5e10\u7bf7\u3001\u6bdb\u5dfe\u88ab\u548c\u538b\u7f29\u997c\u5e72\u7b49\uff0c\u4ef7\u503c50\u4e07\u7f8e\u5143\u3002\u4e2d\u56fd\u653f\u5e9c\u8fd8\u5411\u7f05\u7538\u653f\u5e9c\u63d0\u4f9b\u4e8650\u4e07\u7f8e\u5143\u7684\u73b0\u6c47\u63f4\u52a9\u3002\uff08\u65b0\u534e\uff09<\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\"><CENTER><IMG src=\"http:\/\/cimg20.163.com\/cnews\/2008\/5\/7\/2008050722463139852.jpg\" border=0><\/CENTER><P><\/P><P style=\"TEXT-INDENT: 2em\"><\/P><P style=\"TEXT-INDENT: 2em\">5\u67087\u65e5\uff0c\u5728\u7f05\u7538\u4ef0\u5149\u56fd\u9645\u673a\u573a\uff0c\u5de5\u4f5c\u4eba\u5458\u5728\u642c\u8fd0\u4e2d\u56fd\u7684\u63f4\u52a9\u7269\u8d44\u3002\uff08\u65b0\u534e\uff09<\/P><P style=\"TEXT-INDENT: 2em\">(\u672c\u6587\u6765\u6e90\uff1a\u65b0\u534e\u7f51  \u4f5c\u8005\uff1a\u5f20\u4e91\u98de)","smalltext":"\u4e2d\u56fd\u653f\u5e9c\u5411\u7f05\u7538\u653f\u5e9c\u63d0\u4f9b\u7684\u4eba\u9053\u4e3b\u4e49\u7d27\u6025\u63f4\u52a9\u7269\u8d447\u65e5\u4e0b\u5348\u7a7a\u8fd0\u62b5\u8fbe\u4ef0\u5149\u56fd\u9645\u673a\u573a\u3002","uid":"1","keywords":""},"sced":0}';
					$Id = $args['id'];
					$dg_api_url = $content_url;//$interface_id_by_info['news_details_api'];
					$pam = '&id='.$Id;
					$response_data = $this->http_json($dg_api_url.$pam);
					$data = $response_data['data'];
					return $data;
				}
				if($type_name == 'product_list'){
					$cid = $args['cid'];

					if($interface_id_by_info['product_api']){
						$dg_api_url = $list_url.$interface_id_by_info['product_api'];
						$pam = '&page='.$page.'&cid='.$cid;
						
						$response_data = $this->http_json($dg_api_url.$pam);
						foreach ($response_data['list'] as $key => $vals) {
							$response_data['list'][$key]['url'] = '/pages/content/content?type=product&id='.$vals['id'];
						}
					
					}

					return $response_data;
				}
				if($type_name == 'product_index'){
					
					if($interface_id_by_info['product_index_api']){
						$dg_api_url = $index_url.$interface_id_by_info['product_index_api'];
						$response_data = $this->http_json($dg_api_url);
						$data = $response_data['data'];
	
						foreach ($data  as $keys => $vals) {
							foreach ($vals['list'] as $key => $val) {
								$vals['list'][$key]['url'] = '/pages/content/content?type=product&id='.$val['id'];
							}
							$data[$keys]['list'] = $vals['list'];
			
						}
					}else{
						$data[0]['list'] = '';
					}



					return $data[0]['list'];
				}
				if($type_name == 'product_details'){
					$Id = $args['id'];
					$dg_api_url = $content_url;//$interface_id_by_info['product_details_api'];
					$pam = '&id='.$Id;
					$response_data = $this->http_json($dg_api_url.$pam);
					$data = $response_data['data'];
					return $data;

				}



			}elseif($interface_id_by_info['type'] == 3){
			//wordpress接口
				if($type_name == 'seo'){

				}
				if($type_name == 'banner'){
					
				}
				if($type_name == 'contact'){

				}
				if($type_name == 'news'){

				}
				if($type_name == 'news_index'){

				}

				if($type_name == 'news_index'){

				}

				if($type_name == 'news_list'){
				}

				if($type_name == 'news_details'){

				}
				if($type_name == 'product_list'){

				}
				if($type_name == 'product_index'){

				}
				if($type_name == 'product_details'){
					
				}
			}

		}else{
			
			$query = load()->object('query');

			if($type_name == 'seo'){

				$cid= $args['cid'];
				$id = $args['id'];

				if(!$cid){
					$category_name = "全部";
				}

				$sitename_id_by = pdo_get('yts_qiye_setting',array('id'=>$setting_id),'sitename');
				$sitename = $sitename_id_by['sitename'];

				$p = array('/{sitename}/','/{category_name}/');
				$r = array($sitename,$category_name);

				$types = $args['type_position'];
				if($types){

					$seo_id_by_info = pdo_get('yts_qiye_seo',array('type'=>$types,'setting_id'=>$setting_id));
					$seo_id_by_info['seo_img'] = $this->attach($seo_id_by_info['seo_img']);


					if(($types == 'news' OR $types == 'product') AND $cid){
			
						$category_id_title = pdo_get('yts_qiye_category',array('id'=>$cid),'title');
						$category_name = $category_id_title['title'];
						$r = array($sitename,$category_name);
					}
					if($types == 'news_details'){
						
						$article_id_info = pdo_get('yts_qiye_article',array('id'=>$id));
						$title = $article_id_info['title'];
						$keywords =  $article_id_info['keywords'];
						$ftitle =  $article_id_info['ftitle'];
						$img_path = $this->attach($article_id_info['img_path']);
						$html_message = htmlspecialchars_decode($article_id_info['message']);
						$description = mb_substr(strip_tags($html_message), 0, 50);
						$time = date('Y-m-d H:i:s',$article_id_info['add_time']);

						$category_id_title = pdo_get('yts_qiye_category',array('id'=>$article_id_info['category_id']),'title');
						$category_name = $category_id_title['title'];


						$seo_id_by_info['seo_img'] = $img_path;
						$seo_id_by_info['seo_articleTitle'] = $ftitle;
						$seo_id_by_info['seo_description'] = $description;
						$seo_id_by_info['seo_time'] = $time;
						$p = array('/{sitename}/','/{category_name}/','/{title}/','/{keywords}/');
						$r = array($sitename,$category_name,$title,$keywords);
					}

					if($types == 'product_details'){
						
						$product_id_info = pdo_get('yts_qiye_product',array('id'=>$id));


						// var_dump($product_id_info);
						$title = $product_id_info['title'];
						$keywords =  $product_id_info['keywords'];
						$ftitle =  $product_id_info['ftitle'];
						$img_path = $this->attach($product_id_info['img_path']);
						$html_message = htmlspecialchars_decode($product_id_info['message']);
						$description = mb_substr(strip_tags($html_message), 0, 50);
						$time = date('Y-m-d H:i:s',$product_id_info['add_time']);

						$category_id_title = pdo_get('yts_qiye_category',array('id'=>$product_id_info['category_id']),'title');
						$category_name = $category_id_title['title'];


						$seo_id_by_info['seo_img'] = $img_path;
						$seo_id_by_info['seo_articleTitle'] = $ftitle;
						$seo_id_by_info['seo_description'] = $description;
						$seo_id_by_info['seo_time'] = $time;

						$p = array('/{sitename}/','/{category_name}/','/{title}/','/{keywords}/');
						$r = array($sitename,$category_name,$title,$keywords);
					}




					foreach ($seo_id_by_info as $key => $value) {
						$seo_id_by_info[$key] = preg_replace($p,$r,$value);
					}


					return $seo_id_by_info;
				}

				
			}

			if($type_name == 'banner'){
				if(!$args['type_position'] OR $args['type_position'] > 2){
					$args['type_position'] = 1;
				}
				$banner_id_by_info = $query->from('yts_qiye_banner', 'u')->where('type_position',$args['type_position'])->page($page,$pageNum )->orderby('u.id', 'DESC')->getall();
				foreach ($banner_id_by_info as $key => $value) {
					if($value['img_path']){
						$banner_id_by_info[$key]['img_path'] =  $this->attach($value['img_path']);
						$banner_id_by_info[$key]['images'] =  $banner_id_by_info[$key]['img_path'];
					}else{
						$banner_id_by_info[$key]['images'] = '';
					}
				}

				
				return $banner_id_by_info;
			}

			if($type_name == 'contact'){
				$contact_info = pdo_get('yts_qiye_contact',array('setting_id'=>$setting_id));
				$contact_info['banner'] =   $this->attach($contact_info['banner']);
				$contact_info['pictures'] =   $this->attach($contact_info['pictures']);
				$contact_info['logo'] =   $this->attach($contact_info['logo']);
				return $contact_info;
			}
			
			if($type_name == 'news'){
				$page = $args['page'];
				$pageNum = $args['pageNum'];
				$category_info = $query->from('yts_qiye_category', 'u')->where('type',1)->orderby('u.sort', 'ASC')->getall();
				// var_dump($category_info);

				foreach($category_info as $key => $value){

					$article_id_info =  $query->from('yts_qiye_article', 'u')->where('category_id',$value['id'])->page($page ,$pageNum)->orderby('u.id', 'DESC')->getall();
					$article_id_info = $this->fromat_content($article_id_info,'/pages/content/content?type=news&id=');

					$category_info[$key]['list'] = $article_id_info;
				}
				
				// var_dump($category_info);

				return $article_info;
			}


			if($type_name == 'news_index'){
				$page = $args['page'];
				$pageNum = $args['pageNum'];

				$category_info = $query->from('yts_qiye_category', 'u')->where('type',1)->orderby('u.sort', 'ASC')->getall();
				foreach($category_info as $key => $value){
					$article_id_info =  $query->from('yts_qiye_article', 'u')->where('category_id',$value['id'])->page($page ,$pageNum)->orderby('u.id', 'DESC')->getall();
				
					$article_id_info = $this->fromat_content($article_id_info,'/pages/content/content?type=news&id=');
					$category_info[$key]['list'] = $article_id_info;
				
				}
				$article_all_info = array('title'=>"全部",'type'=>"all");
				$article_all_info['list'] =  $query->from('yts_qiye_article', 'u')->page($page ,$pageNum)->orderby('u.id', 'DESC')->getall();


				$article_all_info['list'] = $this->fromat_content($article_all_info['list'] ,'/pages/content/content?type=news&id=');
	
				$result = array_merge(array($article_all_info), $category_info);
				
				return $result;
			}

			
			if($type_name == 'news_list'){

				$cid = $args['cid'];
				$catNname = "全部";
				$category_info = $query->from('yts_qiye_category', 'u')->where('type',1)->orderby('u.sort', 'ASC')->getall();
				
				$category_info =  array_merge(array(array('title'=>$catNname,'id'=>0)), $category_info);
				
				if($cid){

					$article_info =  $query->from('yts_qiye_article', 'u')->where('category_id',$cid)->page($page ,$pageNum)->orderby('u.id', 'DESC')->getall();
					$total = $query->from('yts_qiye_article', 'u')->where('category_id',$cid)->count();
					$cat_title = pdo_get('yts_qiye_category',array('id'=>$cid),'title');
					$catNname = $cat_title['title'];
					// var_dump($catNname);
				}else{
					$article_info =  $query->from('yts_qiye_article', 'u')->page($page ,$pageNum)->orderby('u.id', 'DESC')->getall();
					$total = $query->from('yts_qiye_article', 'u')->count();
					
				}

				$page_total =  ceil($total/$pageNum );

				
				$article_info = $this->fromat_content($article_info,'/pages/content/content?type=news&id=');

			
				
				return array('category'=>$category_info,'list'=>$article_info,'page_total'=>$page_total,'catName'=>$catNname);
			}
			if($type_name == 'news_details'){
				$Id = $args['id'];
				$product_id_info =  pdo_get('yts_qiye_article',array('id'=>$Id));
				$product_id_info['img_path'] =  $this->attach($product_id_info['img_path']);
				$product_id_info['images'] = $product_id_info['img_path'];
				$product_id_info['addtime'] = date('Y-m-d H:i',$product_id_info['add_time']);
				// var_dump($product_id_info);
				return $product_id_info;
			}

			//产品相关接口
			if($type_name == 'product_list'){

				$cid = $args['cid'];
				// $cid = $args['type'];
				$catNname = "全部";
				$category_info = $query->from('yts_qiye_category', 'u')->where('type',2)->orderby('u.sort', 'ASC')->getall();
				
				$category_info =  array_merge(array(array('title'=>$catNname,'id'=>0)), $category_info);
				
				if($cid){

					$product_info =  $query->from('yts_qiye_product', 'u')->where('category_id',$cid)->page($page ,$pageNum)->orderby('u.id', 'DESC')->getall();
					$total = $query->from('yts_qiye_product', 'u')->where('category_id',$cid)->count();
					$cat_title = pdo_get('yts_qiye_category',array('id'=>$cid),'title');
					$catNname = $cat_title['title'];
					// var_dump($catNname);
				}else{
					$product_info =  $query->from('yts_qiye_product', 'u')->page($page ,$pageNum)->orderby('u.id', 'DESC')->getall();
					$total = $query->from('yts_qiye_product', 'u')->count();
					
				}

				$page_total =  ceil($total/$pageNum );

				
				$product_info = $this->fromat_content($product_info,'/pages/content/content?type=product&id=');

			
				
				return array('category'=>$category_info,'list'=>$product_info,'page_total'=>$page_total,'catName'=>$catNname);
			}

			if($type_name == 'product_index'){
				$page = $args['page'];
				$pageNum = $args['pageNum'];
				$product_info =  $query->from('yts_qiye_product', 'u')->page($page ,$pageNum)->orderby('u.id', 'DESC')->getall();
				$product_info = $this->fromat_content($product_info,'/pages/content/content?type=product&id=');
				return $product_info;
			}

			if($type_name == 'product_details'){
				$Id = $args['id'];
				$product_id_info =  pdo_get('yts_qiye_product',array('id'=>$Id));
				$product_id_info['img_path'] =  $this->attach($product_id_info['img_path']);
				$product_id_info['images'] = $product_id_info['img_path'];
				$product_id_info['addtime'] = date('Y-m-d H:i',$product_id_info['add_time']);

				return $product_id_info;
			}
		}

	}
	
	/**
	 * SEO接口函数 
	 * params type string ;product,product_details,obut,news,news_details,index
	 * {category_name},{sitename}
	 * {title},{keywords}
	 * return array
	*/


	public function doPageSeo(){
		global $_GPC, $_W;
		$setting_id = $this->setting_id;
		$type = $_GPC['type'];
		$cid = $_GPC['cid'];
		$id = $_GPC['id'];
		$data = array();
		if(!$type){
			$type = 'index';
		}

		$seo_id_by_info = $this->Interfaces('seo',array('type_position'=>$type,'id'=>$id,'cid'=>$cid));
		

		$data['info'] = $seo_id_by_info ;
		return $this->result(0, '返回消息', $data);

	}
	public  function doPageSysinfo()
	{
		global $_GPC, $_W;
		$Id = intval($_GPC['setting_id']);
		//首页SEO
		$data = array();
		$setting_id_by_info = pdo_get('yts_qiye_setting',array('id'=>$Id));
		$query = load()->object('query');
		$nav_id_by_info  = $query->from('yts_qiye_nav', 'u')->where('setting_id',$Id)->orderby('u.sort', 'ASC')->getall();
		foreach ($nav_id_by_info as $key => $value) {
			$nav_id_by_info[$key]['img'] = $this->attach($value['img']);
			$nav_id_by_info[$key]['selimg'] = $this->attach($value['selimg']);
			
		}
		$data['info'] = $setting_id_by_info ;
		$data['info']['nav'] = $nav_id_by_info  ;
		return $this->result(0, '返回消息', $data);
	}
	public function doPageContact()
	{
		global $_GPC, $_W;
		$data = $this->Interfaces('contact');
		return $this->result(0, '返回消息', $data);

	}
	public function doPageIndex(){
		global $_GPC, $_W;

		$data = array();
		$query = load()->object('query');

		//轮播图
		$data['banner'] = $this->Interfaces('banner',array('type_position'=>'1'));
		$data['contact'] = $this->Interfaces('contact');

		// //文章接口
		$data['news'] = $this->Interfaces('news_index',array('page'=>1,'pageNum'=>10));
		// //产品接口
		$data['product'] = $this->Interfaces('product_index',array('page'=>1,'pageNum'=>10));
		return $this->result(0, '返回消息', $data);
	}

		// content
	public function doPageNews(){
			global $_GPC, $_W;

			$page = $_GPC['page'];//页面
			$pageNum = $_GPC['pageNum'];
			$cid = $_GPC['cid'];
			if(!$page){
				$page = 1;

			}
			if(!$pageNum){
				$pageNum = 10;
			}
			$data = array();
			$data = $this->Interfaces('news_list',array('cid'=>$cid,'page'=>$page,'pageNum'=>$pageNum));

			$data['show_more'] = 1;
			$data['catname'] = '公司新闻';
			if(!$cid){
				$cid = 0;
			}
			$data['currentCatId'] = $cid;
			$page_total = $data['page_total'];
			if($page_total <= $page){
				$data['show_more'] = 0;
			}
			
			return $this->result(0, '返回消息1', $data);
	}

	// content
	public function doPageNewsContent(){
		global $_GPC, $_W;
		$Id = $_GPC['id'];
		$data = array();
		$errno = 0;
		
		$data = $this->Interfaces('news_details',array('id'=>$Id));
		$message = '返回消息';
	
		return $this->result($errno, $message, $data);
	}

			// content
	public function doPageProduct(){
				global $_GPC, $_W;
				$page = $_GPC['page'];//页面
				$pageNum = $_GPC['pageNum'];
				$cid = $_GPC['cid'];
				if(!$page){
					$page = 1;
	
				}
				if(!$pageNum){
					$pageNum = 10;
	
				}

				$data = array();
				$data['catName'] = '产品展示';
				$data = $this->Interfaces('product_list',array('cid'=>$cid,'page'=>$page,'pageNum'=>$pageNum));
				
				$data['show_more'] = 1;
				//
				// $data['catname'] = '产品展示';
				if(!$cid){
					$cid = 0;
				}
				$data['currentCatId'] = $cid;
				$page_total = $data['page_total'];
				if($page_total <= $page){
					$data['show_more'] = 0;
				}
				
				return $this->result(0, '返回消息1', $data);
	}


		// content
	public function doPageProductContent(){
			global $_GPC, $_W;
			$Id = $_GPC['id'];
			$data = array();
			$errno = 0;
			
		
	
			$data = $this->Interfaces('product_details',array('id'=>$Id));
	
			$message = '返回消息';
		
			return $this->result($errno, $message, $data);
	}

	//BANNER图片
	public function doPageBanner(){
		global $_GPC, $_W;
		$page = $_GPC['page'];
		$pageNum = $_GPC['pageNum'];

		if(!$page ){
			$page  =  1;
		}
		if(!$pageNum ){
			$pageNum  =  100;
		}

		$data = array();
		$errno = 0;
		
		$data = $this->Interfaces('banner',array('type_position'=>2,'page'=>$pagem,'pageNum'=>$pageNum));

		$message = '返回消息';
	
		return $this->result($errno, $message, $data);
}



	public function doPageTest(){
		global $_GPC, $_W;
		$errno = 0;
		$message = '返回消息';
		$data = array();
		return $this->result($errno, $message, $data);
	}


	public function doPageMessageList(){
		global $_GPC, $_W;
		$data = pdo_getall('yts_baiduapp_message', array('uniacid' => $_W['uniacid']), array(), '', 'id desc', 6);
		if (!empty($data)) {
			foreach ($data as &$item) {
				if (strlen($item['message']) > 16) {
					$item['message'] = mb_substr($item['message'], 0, 16) . '...';
				}
			}
		}
		return $this->result(0, '', $data);
	}

	public function doPageAddMessage(){
		global $_GPC, $_W;
		if (!empty($_GPC['message'])) {
			$result = pdo_insert('yts_baiduapp_message', array(
				'nickname' => safe_gpc_string($_GPC['nickname']),
				'message' => safe_gpc_string($_GPC['message']),
				'uniacid' => safe_gpc_string($_W['uniacid']),
			));
		}
		return $this->result(empty($result) ? -1 : 0, '');
	}



}